import org.molamil.acto.core.Logger;
import org.molamil.acto.mc.McTargetResolver;
import org.molamil.acto.mc.mcw.LcMcWrapper;
import org.molamil.acto.pages.master.AbstractMovieMaster;
import org.molamil.commons.ObjectUtil;

/**
 * @author Jorge Hernandez
 */
class org.molamil.acto.pages.master.AbstractInternalMaster extends AbstractMovieMaster {
	
	
	// Properties
	
	private static var log:Logger = Logger.getLogger("AbstractInternalMaster");
	
	
	// Functions
	
	public function display():Void {
		
		log.info("display(), name = " + context.name);
		log.debug("mcWrapper = " + mcWrapper);
		
		var mc:MovieClip = McTargetResolver.getMc(context.target);
		
		if (mc == null)
			log.severe("the mc couldn't be created for: " + context.name);
			
		mcWrapper.mc = mc;
		
		_isDisplayed = true;
		
		ObjectUtil.merge(mcWrapper.mc, context.props);
		ObjectUtil.merge(mcWrapper.mc, request.params);
		
		mcWrapper.state = LcMcWrapper.STATE_IN;
		
	}
	
	public function clear():Void {
		
		log.info("clear(), name = " + context.name);
		
		mcWrapper.state = LcMcWrapper.STATE_OUT;
		
	}
	
	
	// Listeners
	
	private function mcStateChangeListener(eventObject:Object):Void {
		
		super.mcStateChangeListener(eventObject);
		
		log.debug("mcStateChangeListener(), name = " + context.name);
		log.debug("state = " + eventObject.state);
		
		if (eventObject.state == LcMcWrapper.STATE_OFF)
			_isDisplayed = false;
			
	}
	
	
}
